<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>测试在地图中弹出popup</title>
<meta name="description" content="Source code generated using layoutit.com">
<meta name="author" content="LayoutIt!">
<link rel="stylesheet" href="../lib/ol/ol.css" type="text/css">
<script type="text/javascript" src="http://127.0.0.1:8080/map/api?ver=1.0&dev=1"></script>
<style type="text/css">
.map {
  height: 400px;
  width: 100%;
}
</style>
</head>
<body>
	<h2>我的地图</h2>
    <div id="map" class="map"></div>
</body>

<script type="text/javascript">
(function(){
    var map = T.map('map').setView([126.7023, 45.7441], 8);
    
    var osm = new T.osmTile();
    
    map.addLayer(osm);
    
    //放置一个标记,点击时弹出信息
    T.marker([126.7023, 45.7441]).addTo(map)
		.bindPopup("<b>Hello world!</b><br />I am a popup.",{offsetY:-41}).openPopup();
    
    
    //点击其它地方时出现Popup
    var popup = new T.popup();
	function onMapClick(e) {  
	    popup
			.setPosition(e.latlng)
			.setContent("您点击的位置是: "+e.coords[0]+"-"+e.coords[1])
			.openOn(map);
	}
	
	map.on('singleclick', onMapClick);

})();
</script>
</html>